package com.itheima.idea;

import java.util.Random;
public class A3 {
    public static void main(String[] args) {
        //创建随机数对象
        Random r = new Random();
        //定义一个int类型的数组,用来存储奖项
        int arr[] = {888, 666, 222, 1000, 10000};
        int count[] = new int[5];
        //使用for循环嵌套,来保证抽奖不重复
        for (int i = 0; i < arr.length; i++) {
            count [i]= r.nextInt(arr.length);

            for (int j = 0; j <i ; j++) {
                if(count[i] == count[j]){
                    count [i] = 0;
                    i--;
                }
            }
        }
        for (int i = 0; i < count.length; i++) {
            System.out.println(count[i]);
        }
        System.out.println("-----");
        for (int i = 0; i < arr.length; i++) {
            System.out.println("抽出的奖项为:"+arr[count[i]]);
        }
    }
}






